package com.guzhi.service.impl;

import com.guzhi.mapper.DeptMapper;
import com.guzhi.pojo.Dept;
import com.guzhi.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class  DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptmapper;

    @Override
    public List<Dept> findAll() {
        return deptmapper.findAll();
    }

    @Override
    public void deleteById(Integer id) {
        deptmapper.deleteById(id);
    }

    @Override
    public void add(Dept dept) {
        //把剩余字段填充完整（CreateTime，UpdateTime）
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptmapper.add(dept);

    }

    @Override
    public Dept update1(Integer id) {
        return deptmapper.update1(id);
    }

    @Override
    public void update(Dept dept) {
        //把剩余字段填充完整（UpdateTime）
        dept.setUpdateTime(LocalDateTime.now());
        deptmapper.updateById(dept);
    }
}
